
//Table A5 final run

///This is the balanced panel. 
log using "$rootpath/log/Table_A5_Results.log", replace
eststo clear
use "$rootpath/processed_data/Estimation_Data.dta", clear

reghdfe  log_damage55 treatXpost if year>2009, absorb(facility_id n5#year) vce(cluster facility_id)
estimates store outlier_damage

//Emissions results
reghdfe  log_emissions4 treatXpost if year>2009, absorb(facility_id n5#year) vce(cluster facility_id)
estimates store outlier_emission

drop if key_estimation_sample==0
sort facility_id year
egen num_obs=nvals(year), by(facility_id)

//Balanced sample damages. 
reghdfe  log_damage55 treatXpost if num_obs==10, absorb(facility_id n5#year) vce(cluster facility_id)
estimates store balanced_damage

///This is balanced sample emissions
reghdfe  log_emissions4 treatXpost if num_obs==10, absorb(facility_id n5#year) vce(cluster facility_id)
estimates store balanced_emission

//This is extreme damages outliers dropped, 100 million
reghdfe  log_damage55 treatXpost if key_estimation_sample==1&tot_damage<1e8, absorb(facility_id n5#year) vce(cluster facility_id)
estimates store no_outlier_damage

//100 million, emissions
reghdfe  log_emissions4 treatXpost if key_estimation_sample==1&tot_damage<1e8, absorb(facility_id n5#year) vce(cluster facility_id)
estimates store no_outlier_emission

//Main results six digit naics. 
reghdfe  log_damage55 treatXpost if key_estimation_sample==1, absorb(facility_id naics#year) vce(cluster facility_id)
estimates store naics6_damage

//Main results six digit naics. 
reghdfe  log_emissions4 treatXpost if key_estimation_sample==1, absorb(facility_id naics#year) vce(cluster facility_id)
estimates store naics6_emission


esttab naics6_damage outlier_damage balanced_damage no_outlier_damage naics6_emission outlier_emission balanced_emission no_outlier_emission using "$rootpath/table_graph/TBL_A5.tex",  star( * 0.1 ** 0.05 *** 0.01) cells(b(star fmt(3)) se(par fmt(3))) keep(treatXpost _cons) scalars(N F) ar2 replace 

log close
 
